<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Home</title>
</head>
<body>
 <h1>{{name}}</h1>

 <button id="send">Send</button>

<!--<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>-->
 <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
 <script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
 <script src="/public/js/stomp.js"></script>
 <script>
     // 获得Stomp client对象
     var RABBITMQ_ADDRESS= '192.168.99.100:15674';
     var ws = new WebSocket('ws://'+RABBITMQ_ADDRESS+'/ws');
     var client = Stomp.over(ws);
//     var client = Stomp.overWS('ws://192.168.99.100:15674/stomp');
     // SockJS does not support heart-beat: disable heart-beats
     // 设置心跳
     client.heartbeat.outgoing = 0;
     client.heartbeat.incoming = 0;

     // 定义连接成功回调函数
     var on_connect = function(x) {
         //data.body是接收到的数据
         client.subscribe("/exchange/eoa-exchange-direct/reply", function(data) {
             var msg = data.body;
             alert("收到数据：" + msg);
         });
     };

     // 定义错误时回调函数
     var on_error =  function() {
         console.log('error');
     };

     // 连接RabbitMQ
     client.connect('guest', 'guest', on_connect, on_error, '/');
     console.log(">>>连接上" + RABBITMQ_ADDRESS);

     $('#send').on('click',function () {
         client.send('/exchange/eoa-exchange-direct/formTo',null,JSON.stringify({Hello:'world'}));
     })
 </script>
</body>
</html>